package com.protocols.sctp.m3ua.sccp.tcap.camel;

import java.io.Serializable;

import com.protocols.BCDNumber;
import com.protocols.OctaveInteger;
import com.protocols.ProtoOperations;
import com.protocols.ProtocolStackException;
import com.protocols.sctp.m3ua.sccp.tcap.TcapBegin;
import com.protocols.sctp.m3ua.sccp.tcap.TcapConstructor;
import com.protocols.sctp.m3ua.sccp.tcap.TcapPrimitiveUnitByteArray;
import com.protocols.sctp.m3ua.sccp.tcap.TcapPrimitiveUnitNumber;

public class CamelApplyCharging extends CamelInvoke implements Serializable{
	
	private TcapConstructor Parameters = new TcapConstructor(0x30);
	private TcapConstructor ChargingCharasteristics = new TcapConstructor(0x80);
	private TcapConstructor TimeDurationChargingContainer = new TcapConstructor(0xa0);
	private TcapPrimitiveUnitNumber MaxCallPeriod = new TcapPrimitiveUnitNumber(0x80);
	private TcapPrimitiveUnitByteArray ReleaseIfDurationExceed = new TcapPrimitiveUnitByteArray(0xa1);
	private TcapConstructor LegIDContainer = new TcapConstructor(0xa2);
	private TcapPrimitiveUnitNumber SendingSideID = new TcapPrimitiveUnitNumber(0x80);	
	private TcapPrimitiveUnitByteArray Extensions = new TcapPrimitiveUnitByteArray(0xa3);
	
	public CamelApplyCharging() {
		super();	
		super.Invoke.addElement(Parameters);
		Parameters.addElement(ChargingCharasteristics);
		ChargingCharasteristics.addElement(TimeDurationChargingContainer);
		TimeDurationChargingContainer.addElement(MaxCallPeriod);
		TimeDurationChargingContainer.addElement(ReleaseIfDurationExceed);
		Parameters.addElement(LegIDContainer);
		LegIDContainer.addElement(SendingSideID);
		Parameters.addElement(Extensions);
		setOpCode(35,true);	// Apply Charging
		
	}
		
	
	
	public TcapConstructor getRootComponent(){
		return Invoke;
	}
	
	public void setSendingSideID( int legid){
			SendingSideID.setTagValue(legid);
	}
	
	
	public int getLegId(){
		
			return (int)SendingSideID.getTagValue();			
		
		
	}



	public int getMaxCallPeriod() {
		return (int)MaxCallPeriod.getTagValue();
	}



	public void setMaxCallPeriod(int maxCallPeriod) {
		MaxCallPeriod.setTagValue( maxCallPeriod);
	}



	public Boolean releaseIfDurationExceed() {
		return (ReleaseIfDurationExceed.getTagValue()[0]&0xff) ==1;
	}



	public void setReleaseIfDurationExceed(Boolean releaseIfDurationExceed) {
		ReleaseIfDurationExceed.setTagValue(new byte [] {(byte)(releaseIfDurationExceed?1:0),1,(byte)0xff}) ;
	}
	
}
